<?php

namespace App\Http\Middleware;

use Closure;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Redis;
use \Tymon\JWTAuth\Facades\JWTAuth;

class CheckMemberLogin
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    public function handle(Request $request, Closure $next)
    {
       if(!Auth::guard('member')->check()){
//           if($old_token =Redis::get($request->header('token'))){
//               $token = auth('api')->refresh();
//               Redis::del($request->header('token'));
//               Redis::set($token,$token,'EX',60*3);
//               $request->headers->set('token',$token);
//               return $next($request);
//           }else{
               return response()->json(['code'=>401,'msg'=>'登录态过期']);
//           }
       }else{
           return $next($request);
       }
    }
}
